home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 127 / PC Guia 127.iso / Software / Produtividade / OpenOffice.org 2.0.1 / openofficeorg2.cab / wordml2ooo_table.xsl < prev    next >
Extensible Markup Language  |  2005-09-10  |  84KB  |  1,288 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.  
  4.     OpenOffice.org - a multi-platform office productivity suite
  5.  
  6.     $RCSfile: wordml2ooo_table.xsl,v $
  7.  
  8.     $Revision: 1.8 $
  9.  
  10.     last change: $Author: rt $ $Date: 2005/09/08 22:13:21 $
  11.  
  12.     The Contents of this file are made available subject to
  13.     the terms of GNU Lesser General Public License Version 2.1.
  14.  
  15.  
  16.       GNU Lesser General Public License Version 2.1
  17.       =============================================
  18.       Copyright 2005 by Sun Microsystems, Inc.
  19.       901 San Antonio Road, Palo Alto, CA 94303, USA
  20.  
  21.       This library is free software; you can redistribute it and/or
  22.       modify it under the terms of the GNU Lesser General Public
  23.       License version 2.1, as published by the Free Software Foundation.
  24.  
  25.       This library is distributed in the hope that it will be useful,
  26.       but WITHOUT ANY WARRANTY; without even the implied warranty of
  27.       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  28.       Lesser General Public License for more details.
  29.  
  30.       You should have received a copy of the GNU Lesser General Public
  31.       License along with this library; if not, write to the Free Software
  32.       Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  33.       MA  02111-1307  USA
  34.  
  35. -->
  36. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" exclude-result-prefixes="w wx aml o dt  v">
  37.     <xsl:template match="w:style[@w:type='table']" mode="table">
  38.         <style:style style:family="table">
  39.             <xsl:attribute name="style:name">
  40.                 <xsl:value-of select="concat('w',translate(@w:styleId,' ~`!@#$%^*(&)+/,;?<>{}[]:','_'))"/>
  41.             </xsl:attribute>
  42.             <xsl:if test="w:basedOn">
  43.                 <xsl:attribute name="style:parent-style-name">
  44.                     <xsl:value-of select="concat('w',translate(w:basedOn/@w:val,' ~`!@#$%^*(&)+/,;?<>{}[]:','_'))"/>
  45.                 </xsl:attribute>
  46.             </xsl:if>
  47.             <style:table-properties table:align="margins"/>
  48.         </style:style>
  49.     </xsl:template>
  50.     <xsl:template match="w:tblPr" mode="style">
  51.         <xsl:element name="style:style">
  52.             <xsl:attribute name="style:name">Table<xsl:number count="w:tbl" from="/w:wordDocument/w:body" level="any" format="1"/>
  53.             </xsl:attribute>
  54.             <xsl:attribute name="style:family">table</xsl:attribute>
  55.             <xsl:if test="w:tblStyle">
  56.                 <xsl:attribute name="style:parent-style-name">
  57.                     <xsl:value-of select="concat('w',translate(w:tblStyle/@w:val,' ~`!@#$%^*(&)+/,;?<>{}[]:','_'))"/>
  58.                 </xsl:attribute>
  59.             </xsl:if>
  60.             <xsl:variable name="section-property-number" select="count(preceding::w:sectPr)"/>
  61.             <xsl:variable name="last-section-property" select="preceding::w:pPr/w:sectPr[1]"/>
  62.             <xsl:variable name="next-section-property" select="following::w:sectPr[1]"/>
  63.             <xsl:variable name="last-next-p-tbl" select="$last-section-property[last()]/following::*[name()='w:p' or name()='w:tbl']"/>
  64.             <xsl:if test="not($next-section-property/w:type/@w:val = 'continuous') and  generate-id($last-next-p-tbl[1]) = generate-id(..) and not(ancestor::w:sectPr or ancestor::w:styles)">
  65.                 <xsl:attribute name="style:master-page-name">Standard<xsl:value-of select="$section-property-number + 1"/>
  66.                 </xsl:attribute>
  67.             </xsl:if>
  68.             <xsl:element name="style:table-properties">
  69.                 <xsl:choose>
  70.                     <xsl:when test="w:jc/@w:val = 'left' or w:jc/@w:val = 'center' or w:jc/@w:val = 'right'">
  71.                         <xsl:attribute name="table:align">
  72.                             <xsl:value-of select="w:jc/@w:val"/>
  73.                         </xsl:attribute>
  74.                     </xsl:when>
  75.                     <xsl:otherwise>
  76.                         <xsl:attribute name="table:align">margins</xsl:attribute>
  77.                     </xsl:otherwise>
  78.                 </xsl:choose>
  79.                 <!-- adopt the width of table and column corresponding the width of page and margins. . -->
  80.                 <xsl:variable name="sectPr" select="following::w:sectPr[1]"/>
  81.                 <xsl:variable name="total-page-size" select="$sectPr/w:pgSz/@w:w"/>
  82.                 <xsl:variable name="page-left-mar" select="$sectPr/w:pgMar/@w:left"/>
  83.                 <xsl:variable name="page-right-mar" select="$sectPr/w:pgMar/@w:right"/>
  84.                 <xsl:variable name="page-size-value" select="$total-page-size - $page-left-mar - $page-right-mar"/>
  85.                 <xsl:variable name="page-size-inch">
  86.                     <xsl:call-template name="ConvertMeasure">
  87.                         <xsl:with-param name="TargetMeasure" select="'in'"/>
  88.                         <xsl:with-param name="value" select="concat($page-size-value, 'twip') "/>
  89.                     </xsl:call-template>
  90.                 </xsl:variable>
  91.                 <xsl:variable name="gridcols" select="../w:tblGrid/w:gridCol"/>
  92.                 <xsl:variable name="tblsize" select="sum($gridcols/@w:w)"/>
  93.                 <xsl:variable name="table_indent">
  94.                     <xsl:choose>
  95.                         <xsl:when test="w:tblInd and  w:tblInd/@w:w > 0 ">
  96.                             <xsl:call-template name="ConvertMeasure">
  97.                                 <xsl:with-param name="TargetMeasure" select="'in'"/>
  98.                                 <xsl:with-param name="value" select="concat(w:tblInd/@w:w, 'twip') "/>
  99.                             </xsl:call-template>
  100.                         </xsl:when>
  101.                         <xsl:otherwise>
  102.                             <xsl:value-of select="number( '0') "/>
  103.                         </xsl:otherwise>
  104.                     </xsl:choose>
  105.                 </xsl:variable>
  106.                 <xsl:variable name="rel-tblsize">
  107.                     <xsl:choose>
  108.                         <xsl:when test="w:tblW/@w:type = 'pct'">
  109.                             <xsl:value-of select="(number(w:tblW/@w:w  ) div 5000) * $page-size-inch"/>
  110.                         </xsl:when>
  111.                         <xsl:otherwise>
  112.                             <xsl:call-template name="ConvertMeasure">
  113.                                 <xsl:with-param name="TargetMeasure" select="'in'"/>
  114.                                 <xsl:with-param name="value" select="concat($tblsize, 'twip')"/>
  115.                             </xsl:call-template>
  116.                         </xsl:otherwise>
  117.                     </xsl:choose>
  118.                 </xsl:variable>
  119.                 <xsl:attribute name="style:width">
  120.                     <xsl:value-of select="concat($rel-tblsize, 'in' )"/>
  121.                 </xsl:attribute>
  122.                 <xsl:variable name="tbl_margin_left">
  123.                     <xsl:choose>
  124.                         <xsl:when test="not(w:tblpPr ) ">
  125.                             <xsl:choose>
  126.                                 <xsl:when test="w:bidiVisual">
  127.                                     <xsl:choose>
  128.                                         <xsl:when test=" number($page-size-inch - $table_indent - $rel-tblsize) > 0">
  129.                                             <xsl:value-of select="$page-size-inch - $table_indent - $rel-tblsize"/>
  130.                                         </xsl:when>
  131.                                         <xsl:otherwise>
  132.                                             <xsl:text>0</xsl:text>
  133.                                         </xsl:otherwise>
  134.                                     </xsl:choose>
  135.                                 </xsl:when>
  136.                                 <xsl:otherwise>
  137.                                     <xsl:value-of select="$table_indent"/>
  138.                                 </xsl:otherwise>
  139.                             </xsl:choose>
  140.                         </xsl:when>
  141.                         <xsl:when test="w:tblpPr">
  142.                             <!-- if the table is  put into a draw:text-box,  fo:margin-left and fo:margin-right should be 0 -->
  143.                             <xsl:text>0</xsl:text>
  144.                         </xsl:when>
  145.                     </xsl:choose>
  146.                 </xsl:variable>
  147.                 <xsl:variable name="tbl_margin_right">
  148.                     <xsl:choose>
  149.                         <xsl:when test="not(w:tblpPr ) ">
  150.                             <xsl:choose>
  151.                                 <xsl:when test="w:bidiVisual">
  152.                                     <xsl:value-of select="$table_indent"/>
  153.                                 </xsl:when>
  154.                                 <xsl:otherwise>
  155.                                     <xsl:choose>
  156.                                         <xsl:when test=" number($page-size-inch - $table_indent - $rel-tblsize) > 0">
  157.                                             <xsl:value-of select="$page-size-inch - $table_indent - $rel-tblsize"/>
  158.                                         </xsl:when>
  159.                                         <xsl:otherwise>
  160.                                             <xsl:text>0</xsl:text>
  161.                                         </xsl:otherwise>
  162.                                     </xsl:choose>
  163.                                 </xsl:otherwise>
  164.                             </xsl:choose>
  165.                         </xsl:when>
  166.                         <xsl:when test="w:tblpPr">
  167.                             <!-- if the table is  put into a draw:text-box,  fo:margin-left and fo:margin-right should be 0 -->
  168.                             <xsl:text>0</xsl:text>
  169.                         </xsl:when>
  170.                     </xsl:choose>
  171.                 </xsl:variable>
  172.                 <xsl:attribute name="fo:margin-left">
  173.                     <xsl:value-of select="concat( $tbl_margin_left, 'in')"/>
  174.                 </xsl:attribute>
  175.                 <xsl:attribute name="fo:margin-right">
  176.                     <xsl:value-of select="concat($tbl_margin_right, 'in')"/>
  177.                 </xsl:attribute>
  178.                 <!-- If previous w:p has a page break, the table must have the page break attribute applied to it     May need this for tables starting on new pages -->
  179.                 <!--    <xsl:if test="parent::w:tbl/preceding-sibling::w:p[1][descendant::w:br/@w:type='page']">
  180.                             <xsl:attribute name="fo:break-before">page</xsl:attribute></xsl:if>    -->
  181.                 <!-- initial values for tables-->
  182.             </xsl:element>
  183.         </xsl:element>
  184.         <!-- the following style is for conveting Word table text wrapping to SO Writer. Since SO Writer has no table text wrapping feature, so we use the draw:text-box as a container and put the table in draw:text-box -->
  185.         <xsl:if test="w:tblpPr">
  186.             <xsl:element name="style:style">
  187.                 <xsl:attribute name="style:name">TableFrame<xsl:number count="w:tblpPr" from="/w:wordDocument/w:body" level="any" format="1"/>
  188.                 </xsl:attribute>
  189.                 <xsl:attribute name="style:family">graphic</xsl:attribute>
  190.                 <xsl:attribute name="style:parent-style-name">
  191.                     <xsl:value-of select=" 'Frame' "/>
  192.                 </xsl:attribute>
  193.                 <xsl:element name="style:graphic-properties">
  194.                     <xsl:if test="w:tblpPr/@w:leftFromText">
  195.                         <xsl:variable name="left_margin_from_text">
  196.                             <xsl:call-template name="ConvertMeasure">
  197.                                 <xsl:with-param name="TargetMeasure" select="'in'"/>
  198.                                 <xsl:with-param name="value" select="concat (w:tblpPr/@w:leftFromText, 'twip') "/>
  199.                             </xsl:call-template>
  200.                         </xsl:variable>
  201.                         <xsl:attribute name="fo:margin-left">
  202.                             <xsl:value-of select="concat( $left_margin_from_text, 'in') "/>
  203.                         </xsl:attribute>
  204.                     </xsl:if>
  205.                     <xsl:if test="w:tblpPr/@w:rightFromText">
  206.                         <xsl:variable name="right_margin_from_text">
  207.                             <xsl:call-template name="ConvertMeasure">
  208.                                 <xsl:with-param name="TargetMeasure" select="'in'"/>
  209.                                 <xsl:with-param name="value" select="concat (w:tblpPr/@w:rightFromText, 'twip') "/>
  210.                             </xsl:call-template>
  211.                         </xsl:variable>
  212.                         <xsl:attribute name="fo:margin-right">
  213.                             <xsl:value-of select="concat( $right_margin_from_text, 'in') "/>
  214.                         </xsl:attribute>
  215.                     </xsl:if>
  216.                     <xsl:if test="w:tblpPr/@w:topFromText">
  217.                         <xsl:variable name="top_margin_from_text">
  218.                             <xsl:call-template name="ConvertMeasure">
  219.                                 <xsl:with-param name="TargetMeasure" select="'in'"/>
  220.                                 <xsl:with-param name="value" select="concat (w:tblpPr/@w:topFromText, 'twip') "/>
  221.                             </xsl:call-template>
  222.                         </xsl:variable>
  223.                         <xsl:attribute name="fo:margin-top">
  224.                             <xsl:value-of select="concat( $top_margin_from_text, 'in') "/>
  225.                         </xsl:attribute>
  226.                     </xsl:if>
  227.                     <xsl:if test="w:tblpPr/@w:bottomFromText">
  228.                         <xsl:variable name="bottom_margin_from_text">
  229.                             <xsl:call-template name="ConvertMeasure">
  230.                                 <xsl:with-param name="TargetMeasure" select="'in'"/>
  231.                                 <xsl:with-param name="value" select="concat (w:tblpPr/@w:bottomFromText, 'twip') "/>
  232.                             </xsl:call-template>
  233.                         </xsl:variable>
  234.                         <xsl:attribute name="fo:margin-bottom">
  235.                             <xsl:value-of select="concat( $bottom_margin_from_text, 'in') "/>
  236.                         </xsl:attribute>
  237.                     </xsl:if>
  238.                     <xsl:attribute name="style:number-wrapped-paragraphs">
  239.                         <xsl:text>no-limit</xsl:text>
  240.                     </xsl:attribute>
  241.                     <!--xsl:if test="w:tblpPr/@w:tblpYSpec" to get the vertical alignment-->
  242.                     <xsl:variable name="vertical_alignment">
  243.                         <xsl:choose>
  244.                             <xsl:when test="w:tblpPr/@w:tblpYSpec = 'top' ">
  245.                                 <xsl:text>top</xsl:text>
  246.                             </xsl:when>
  247.                             <xsl:when test="w:tblpPr/@w:tblpYSpec = 'center' ">
  248.                                 <xsl:text>middle</xsl:text>
  249.                             </xsl:when>
  250.                             <xsl:when test="w:tblpPr/@w:tblpYSpec= 'bottom' ">
  251.                                 <xsl:text>bottom</xsl:text>
  252.                             </xsl:when>
  253.                             <xsl:when test="w:tblpPr/@w:tblpYSpec = 'inside' ">
  254.                                 <xsl:text>from-top</xsl:text>
  255.                             </xsl:when>
  256.                             <xsl:when test="w:tblpPr/@w:tblpYSpec= 'outside' ">
  257.                                 <xsl:text>top</xsl:text>
  258.                             </xsl:when>
  259.                             <xsl:otherwise>
  260.                                 <xsl:text>from-top</xsl:text>
  261.                             </xsl:otherwise>
  262.                         </xsl:choose>
  263.                     </xsl:variable>
  264.                     <xsl:attribute name="style:vertical-pos">
  265.                         <xsl:value-of select="$vertical_alignment"/>
  266.                     </xsl:attribute>
  267.                     <!--/xsl:if-->
  268.                     <!--xsl:if test="w:tblpPr/@w:vertAnchor" to get the vertical anchor related area type -->
  269.                     <xsl:variable name="frame_v_anchor">
  270.                         <xsl:choose>
  271.                             <xsl:when test="w:tblpPr/@w:vertAnchor = 'text' ">
  272.                                 <xsl:value-of select=" 'paragraph' "/>
  273.                             </xsl:when>
  274.                             <xsl:when test="w:tblpPr/@w:vertAnchor = 'margin' ">
  275.                                 <xsl:value-of select=" 'paragraph-content' "/>
  276.                             </xsl:when>
  277.                             <xsl:when test="w:tblpPr/@w:vertAnchor = 'page' ">
  278.                                 <xsl:value-of select="w:tblpPr/@w:vertAnchor"/>
  279.                             </xsl:when>
  280.                             <xsl:otherwise>
  281.                                 <xsl:value-of select=" 'page-content' "/>
  282.                             </xsl:otherwise>
  283.                         </xsl:choose>
  284.                     </xsl:variable>
  285.                     <xsl:attribute name="style:vertical-rel">
  286.                         <xsl:value-of select="$frame_v_anchor"/>
  287.                     </xsl:attribute>
  288.                     <!--/xsl:if-->
  289.                     <!--xsl:if test="w:tblpPr/@w:tblpXSpec" to get the horizntal alignment-->
  290.                     <xsl:variable name="horizental_alignment">
  291.                         <xsl:choose>
  292.                             <xsl:when test="w:tblpPr/@w:tblpXSpec = 'left' ">
  293.                                 <xsl:text>left</xsl:text>
  294.                             </xsl:when>
  295.                             <xsl:when test="w:tblpPr/@w:tblpXSpec = 'center' ">
  296.                                 <xsl:text>center</xsl:text>
  297.                             </xsl:when>
  298.                             <xsl:when test="w:tblpPr/@w:tblpXSpec = 'right' ">
  299.                                 <xsl:text>right</xsl:text>
  300.                             </xsl:when>
  301.                             <xsl:when test="w:tblpPr/@w:tblpXSpec = 'inside' ">
  302.                                 <xsl:text>from-left</xsl:text>
  303.                             </xsl:when>
  304.                             <xsl:when test="w:tblpPr/@w:tblpXSpec = 'outside' ">
  305.                                 <xsl:text>outside</xsl:text>
  306.                             </xsl:when>
  307.                             <xsl:otherwise>
  308.                                 <xsl:text>left</xsl:text>
  309.                             </xsl:otherwise>
  310.                         </xsl:choose>
  311.                     </xsl:variable>
  312.                     <xsl:attribute name="style:horizontal-pos">
  313.                         <xsl:value-of select="$horizental_alignment"/>
  314.                     </xsl:attribute>
  315.                     <!--/xsl:if-->
  316.                     <!--xsl:if test="w:tblpPr/@w:horzAnchor" to get the horizental anchor related area type-->
  317.                     <xsl:variable name="frame_h_anchor">
  318.                         <xsl:choose>
  319.                             <xsl:when test="w:tblpPr/@w:horzAnchor = 'text' ">
  320.                                 <xsl:value-of select=" 'paragraph' "/>
  321.                             </xsl:when>
  322.                             <xsl:when test="w:tblpPr/@w:horzAnchor = 'margin' ">
  323.                                 <xsl:value-of select=" 'page-content' "/>
  324.                             </xsl:when>
  325.                             <xsl:when test="w:tblpPr/@w:horzAnchor = 'page' ">
  326.                                 <xsl:value-of select="w:tblpPr/@w:horzAnchor"/>
  327.                             </xsl:when>
  328.                             <xsl:when test="w:tblpPr/@w:horzAnchor= 'inside' ">
  329.                                 <xsl:value-of select=" 'paragraph-start-margin' "/>
  330.                             </xsl:when>
  331.                             <xsl:when test="w:tblpPr/@w:horzAnchor= 'outside' ">
  332.                                 <xsl:value-of select=" 'paragraph-end-margin' "/>
  333.                             </xsl:when>
  334.                             <xsl:otherwise>
  335.                                 <xsl:value-of select=" 'paragraph-content' "/>
  336.                             </xsl:otherwise>
  337.                         </xsl:choose>
  338.                     </xsl:variable>
  339.                     <xsl:attribute name="style:horizontal-rel">
  340.                         <xsl:value-of select="$frame_h_anchor"/>
  341.                     </xsl:attribute>
  342.                     <!--/xsl:if-->
  343.                     <xsl:attribute name="fo:background-color">
  344.                         <xsl:text>#ffffff</xsl:text>
  345.                     </xsl:attribute>
  346.                     <!-- xsl:attribute name="style:background-transparency"><xsl:text>100%</xsl:text></xsl:attribute -->
  347.                     <xsl:attribute name="style:wrap">
  348.                         <xsl:text>parallel</xsl:text>
  349.                     </xsl:attribute>
  350.                 </xsl:element>
  351.             </xsl:element>
  352.         </xsl:if>
  353.     </xsl:template>
  354.     <xsl:template match="w:gridCol" mode="style">
  355.         <xsl:element name="style:style">
  356.             <xsl:attribute name="style:family">table-column</xsl:attribute>
  357.             <xsl:attribute name="style:name">Table<xsl:number count="w:tbl" from="/w:wordDocument/w:body" level="any" format="1"/>.C<xsl:number count="w:gridCol" from="/w:wordDocument/w:body" level="single" format="1"/>
  358.             </xsl:attribute>
  359.             <xsl:element name="style:table-column-properties">
  360.                 <xsl:variable name="column_width">
  361.                     <xsl:call-template name="ConvertMeasure">
  362.                         <xsl:with-param name="TargetMeasure" select="'in'"/>
  363.                         <xsl:with-param name="value" select="concat(@w:w, 'twip') "/>
  364.                     </xsl:call-template>
  365.                 </xsl:variable>
  366.                 <xsl:attribute name="style:column-width">
  367.                     <xsl:value-of select="concat($column_width,'in') "/>
  368.                 </xsl:attribute>
  369.             </xsl:element>
  370.         </xsl:element>
  371.     </xsl:template>
  372.     <xsl:template match="w:trPr" mode="style">
  373.         <!-- to generate style:style of table-row height.  -->
  374.         <xsl:element name="style:style">
  375.             <xsl:attribute name="style:family">table-row</xsl:attribute>
  376.             <xsl:attribute name="style:name">Table<xsl:number count="w:tbl" from="/w:wordDocument/w:body" level="any" format="1"/>.R<xsl:number count="w:tr" from="/w:wordDocument/w:body" level="single" format="1"/>
  377.             </xsl:attribute>
  378.             <xsl:element name="style:table-row-properties">
  379.                 <xsl:choose>
  380.                     <xsl:when test="w:trHeight/@w:val">
  381.                         <xsl:variable name="tbl_row_height">
  382.                             <xsl:call-template name="ConvertMeasure">
  383.                                 <xsl:with-param name="TargetMeasure" select="'in'"/>
  384.                                 <xsl:with-param name="value" select="concat(w:trHeight/@w:val, 'twip') "/>
  385.                             </xsl:call-template>
  386.                         </xsl:variable>
  387.                         <xsl:attribute name="style:min-row-height">
  388.                             <xsl:value-of select="concat($tbl_row_height, 'in' )"/>
  389.                         </xsl:attribute>
  390.                     </xsl:when>
  391.                 </xsl:choose>
  392.             </xsl:element>
  393.         </xsl:element>
  394.     </xsl:template>
  395.     <xsl:template match="w:tcPr" mode="style">
  396.         <style:style>
  397.             <xsl:attribute name="style:name">Table<xsl:number count="w:tbl" from="/w:wordDocument/w:body" level="any" format="1"/>.R<xsl:number count="w:tr" from="/w:wordDocument/w:body" level="single" format="1"/>C<xsl:number count="w:tc" from="/w:wordDocument/w:body" level="single" format="1"/>
  398.             </xsl:attribute>
  399.             <xsl:attribute name="style:family">table-cell</xsl:attribute>
  400.             <xsl:variable name="rootStyle" select="ancestor::w:tbl/w:tblPr/w:tblStyle/@w:val"/>
  401.             <xsl:variable name="rootStyleNode" select="/w:wordDocument/w:styles/w:style[@w:styleId = $rootStyle]"/>
  402.             <xsl:element name="style:table-cell-properties">
  403.                 <!-- cell background color start -->
  404.                 <xsl:variable name="tbl_cell_background_color">
  405.                     <xsl:choose>
  406.                         <xsl:when test="w:shd/@w:fill">
  407.                             <xsl:value-of select="w:shd/@w:fill"/>
  408.                         </xsl:when>
  409.                         <xsl:when test="$rootStyleNode/w:tblpr/w:shd/@w:fill">
  410.                             <xsl:value-of select="$rootStyleNode/w:tblpr/w:shd/@w:fill"/>
  411.                         </xsl:when>
  412.                     </xsl:choose>
  413.                 </xsl:variable>
  414.                 <xsl:choose>
  415.                     <xsl:when test=" string-length($tbl_cell_background_color) > 0 and not( $tbl_cell_background_color ='auto' )">
  416.                         <xsl:attribute name="fo:background-color">
  417.                             <xsl:value-of select="concat('#',$tbl_cell_background_color)"/>
  418.                         </xsl:attribute>
  419.                     </xsl:when>
  420.                 </xsl:choose>
  421.                 <!--cell background color end -->
  422.                 <!-- table cell vertical alignment start -->
  423.                 <xsl:if test="w:vAlign">
  424.                     <xsl:variable name="tbl_cell_alignment">
  425.                         <xsl:choose>
  426.                             <xsl:when test="w:vAlign/@w:val = 'top' ">
  427.                                 <xsl:text>top</xsl:text>
  428.                             </xsl:when>
  429.                             <xsl:when test="w:vAlign/@w:val = 'center' ">
  430.                                 <xsl:text>middle</xsl:text>
  431.                             </xsl:when>
  432.                             <xsl:when test="w:vAlign/@w:val = 'bottom' ">
  433.                                 <xsl:text>bottom</xsl:text>
  434.                             </xsl:when>
  435.                             <xsl:otherwise>
  436.                                 <xsl:text>automatic</xsl:text>
  437.                             </xsl:otherwise>
  438.                         </xsl:choose>
  439.                     </xsl:variable>
  440.                     <xsl:attribute name="style:vertical-align">
  441.                         <xsl:value-of select="$tbl_cell_alignment"/>
  442.                     </xsl:attribute>
  443.                 </xsl:if>
  444.                 <!--table cell alignment end -->
  445.                 <!-- cell margin start -->
  446.                 <xsl:variable name="tblcell_leftmargin">
  447.                     <xsl:choose>
  448.                         <xsl:when test="w:tcMar/w:left">
  449.                             <xsl:call-template name="convert2in_special">
  450.                                 <xsl:with-param name="original_value" select="concat(w:tcMar/w:left/@w:w , w:tcMar/w:left/@w:type) "/>
  451.                             </xsl:call-template>
  452.                         </xsl:when>
  453.                         <xsl:when test="$rootStyleNode/w:tblPr/w:tblCellMar/w:left">
  454.                             <xsl:call-template name="convert2in_special">
  455.                                 <xsl:with-param name="original_value" select="concat($rootStyleNode/w:tblPr/w:tblCellMar/w:left/@w:w , $rootStyleNode/w:tblPr/w:tblCellMar/w:left/@w:type)"/>
  456.                             </xsl:call-template>
  457.                         </xsl:when>
  458.                         <xsl:otherwise>
  459.                             <xsl:text>0</xsl:text>
  460.                         </xsl:otherwise>
  461.                     </xsl:choose>
  462.                 </xsl:variable>
  463.                 <xsl:variable name="tblcell_rightmargin">
  464.                     <xsl:choose>
  465.                         <xsl:when test="w:tcMar/w:right">
  466.                             <xsl:call-template name="convert2in_special">
  467.                                 <xsl:with-param name="original_value" select="concat(w:tcMar/w:right/@w:w , w:tcMar/w:right/@w:type) "/>
  468.                             </xsl:call-template>
  469.                         </xsl:when>
  470.                         <xsl:when test="$rootStyleNode/w:tblPr/w:tblCellMar/w:right">
  471.                             <xsl:call-template name="convert2in_special">
  472.                                 <xsl:with-param name="original_value" select="concat($rootStyleNode/w:tblPr/w:tblCellMar/w:right/@w:w , $rootStyleNode/w:tblPr/w:tblCellMar/w:right/@w:type)"/>
  473.                             </xsl:call-template>
  474.                         </xsl:when>
  475.                         <xsl:otherwise>
  476.                             <xsl:text>0</xsl:text>
  477.                         </xsl:otherwise>
  478.                     </xsl:choose>
  479.                 </xsl:variable>
  480.                 <xsl:variable name="tblcell_topmargin">
  481.                     <xsl:choose>
  482.                         <xsl:when test="w:tcMar/w:top">
  483.                             <xsl:call-template name="convert2in_special">
  484.                                 <xsl:with-param name="original_value" select="concat(w:tcMar/w:top/@w:w , w:tcMar/w:top/@w:type) "/>
  485.                             </xsl:call-template>
  486.                         </xsl:when>
  487.                         <xsl:when test="$rootStyleNode/w:tblPr/w:tblCellMar/w:top">
  488.                             <xsl:call-template name="convert2in_special">
  489.                                 <xsl:with-param name="original_value" select="concat($rootStyleNode/w:tblPr/w:tblCellMar/w:top/@w:w , $rootStyleNode/w:tblPr/w:tblCellMar/w:top/@w:type)"/>
  490.                             </xsl:call-template>
  491.                         </xsl:when>
  492.                         <xsl:otherwise>
  493.                             <xsl:text>0</xsl:text>
  494.                         </xsl:otherwise>
  495.                     </xsl:choose>
  496.                 </xsl:variable>
  497.                 <xsl:variable name="tblcell_bottommargin">
  498.                     <xsl:choose>
  499.                         <xsl:when test="w:tcMar/w:bottom">
  500.                             <xsl:call-template name="convert2in_special">
  501.                                 <xsl:with-param name="original_value" select="concat(w:tcMar/w:bottom/@w:w , w:tcMar/w:bottom/@w:type) "/>
  502.                             </xsl:call-template>
  503.                         </xsl:when>
  504.                         <xsl:when test="$rootStyleNode/w:tblPr/w:tblCellMar/w:bottom">
  505.                             <xsl:call-template name="convert2in_special">
  506.                                 <xsl:with-param name="original_value" select="concat($rootStyleNode/w:tblPr/w:tblCellMar/w:bottom/@w:w , $rootStyleNode/w:tblPr/w:tblCellMar/w:bottom/@w:type)"/>
  507.                             </xsl:call-template>
  508.                         </xsl:when>
  509.                         <xsl:otherwise>
  510.                             <xsl:text>0</xsl:text>
  511.                         </xsl:otherwise>
  512.                     </xsl:choose>
  513.                 </xsl:variable>
  514.                 <xsl:if test="string-length($tblcell_leftmargin) > 0 ">
  515.                     <xsl:attribute name="fo:padding-left">
  516.                         <xsl:value-of select="concat($tblcell_leftmargin, 'in' )"/>
  517.                     </xsl:attribute>
  518.                 </xsl:if>
  519.                 <xsl:if test="string-length($tblcell_rightmargin) > 0">
  520.                     <xsl:attribute name="fo:padding-right">
  521.                         <xsl:value-of select="concat($tblcell_rightmargin, 'in' )"/>
  522.                     </xsl:attribute>
  523.                 </xsl:if>
  524.                 <xsl:if test="string-length($tblcell_topmargin) > 0 ">
  525.                     <xsl:attribute name="fo:padding-top">
  526.                         <xsl:value-of select="concat($tblcell_topmargin, 'in' )"/>
  527.                     </xsl:attribute>
  528.                 </xsl:if>
  529.                 <xsl:if test="string-length($tblcell_bottommargin) >  0">
  530.                     <xsl:attribute name="fo:padding-bottom">
  531.                         <xsl:value-of select="concat($tblcell_bottommargin, 'in' )"/>
  532.                     </xsl:attribute>
  533.                 </xsl:if>
  534.                 <!-- cell margin end -->
  535.                 <xsl:variable name="row-position">
  536.                     <xsl:number count="w:tr" from="/w:wordDocument/w:body" level="single" format="1"/>
  537.                 </xsl:variable>
  538.                 <!-- cell borders should be carefully converted. a little complex. glu :( -->
  539.                 <xsl:variable name="Borders" select="ancestor::w:tbl/w:tblPr/w:tblBorders"/>
  540.                 <xsl:choose>
  541.                     <xsl:when test="$row-position > 1">
  542.                         <xsl:call-template name="get-table-border">
  543.                             <xsl:with-param name="style-pos" select="'top'"/>
  544.                             <xsl:with-param name="style-position-0" select="w:tcBorders/w:top"/>
  545.                             <xsl:with-param name="style-position-1" select="$Borders/w:insideH"/>
  546.                             <xsl:with-param name="style-position-2" select="$rootStyleNode/w:tblPr/w:tblBorders/w:insideH"/>
  547.                         </xsl:call-template>
  548.                     </xsl:when>
  549.                     <xsl:otherwise>
  550.                         <xsl:call-template name="get-table-border">
  551.                             <xsl:with-param name="style-pos" select="'top'"/>
  552.                             <xsl:with-param name="style-position-0" select="w:tcBorders/w:top"/>
  553.                             <xsl:with-param name="style-position-1" select="$Borders/w:top"/>
  554.                             <xsl:with-param name="style-position-2" select="$rootStyleNode/w:tblPr/w:tblBorders/w:top"/>
  555.                         </xsl:call-template>
  556.                     </xsl:otherwise>
  557.                 </xsl:choose>
  558.                 <xsl:choose>
  559.                     <xsl:when test="count(ancestor::w:tr/following-sibling::w:tr) > 0">
  560.                         <xsl:call-template name="get-table-border">
  561.                             <xsl:with-param name="style-pos" select="'bottom'"/>
  562.                             <xsl:with-param name="style-position-0" select="w:tcBorders/w:bottom"/>
  563.                             <xsl:with-param name="style-position-1" select="$Borders/w:insideH"/>
  564.                             <xsl:with-param name="style-position-2" select="$rootStyleNode/w:tblPr/w:tblBorders/w:insideH"/>
  565.                         </xsl:call-template>
  566.                     </xsl:when>
  567.                     <xsl:otherwise>
  568.                         <xsl:call-template name="get-table-border">
  569.                             <xsl:with-param name="style-pos" select="'bottom'"/>
  570.                             <xsl:with-param name="style-position-0" select="w:tcBorders/w:bottom"/>
  571.                             <xsl:with-param name="style-position-1" select="$Borders/w:bottom"/>
  572.                             <xsl:with-param name="style-position-2" select="$rootStyleNode/w:tblPr/w:tblBorders/w:bottom"/>
  573.                         </xsl:call-template>
  574.                     </xsl:otherwise>
  575.                 </xsl:choose>
  576.                 <xsl:choose>
  577.                     <xsl:when test="count(ancestor::w:tc/preceding-sibling::w:tc) > 0">
  578.                         <xsl:call-template name="get-table-border">
  579.                             <xsl:with-param name="style-pos" select="'left'"/>
  580.                             <xsl:with-param name="style-position-0" select="w:tcBorders/w:left"/>
  581.                             <xsl:with-param name="style-position-1" select="$Borders/w:insideV"/>
  582.                             <xsl:with-param name="style-position-2" select="$rootStyleNode/w:tblPr/w:tblBorders/w:insideV"/>
  583.                         </xsl:call-template>
  584.                     </xsl:when>
  585.                     <xsl:otherwise>
  586.                         <xsl:call-template name="get-table-border">
  587.                             <xsl:with-param name="style-pos" select="'left'"/>
  588.                             <xsl:with-param name="style-position-0" select="w:tcBorders/w:left"/>
  589.                             <xsl:with-param name="style-position-1" select="$Borders/w:left"/>
  590.                             <xsl:with-param name="style-position-2" select="$rootStyleNode/w:tblPr/w:tblBorders/w:left"/>
  591.                         </xsl:call-template>
  592.                     </xsl:otherwise>
  593.                 </xsl:choose>
  594.                 <xsl:choose>
  595.                     <xsl:when test="count(ancestor::w:tc/following-sibling::w:tc) > 0">
  596.                         <xsl:call-template name="get-table-border">
  597.                             <xsl:with-param name="style-pos" select="'right'"/>
  598.                             <xsl:with-param name="style-position-0" select="w:tcBorders/w:right"/>
  599.                             <xsl:with-param name="style-position-1" select="$Borders/w:insideV"/>
  600.                             <xsl:with-param name="style-position-2" select="$rootStyleNode/w:tblPr/w:tblBorders/w:insideV"/>
  601.                         </xsl:call-template>
  602.                     </xsl:when>
  603.                     <xsl:otherwise>
  604.                         <xsl:call-template name="get-table-border">
  605.                             <xsl:with-param name="style-pos" select="'right'"/>
  606.                             <xsl:with-param name="style-position-0" select="w:tcBorders/w:right"/>
  607.                             <xsl:with-param name="style-position-1" select="$Borders/w:right"/>
  608.                             <xsl:with-param name="style-position-2" select="$rootStyleNode/w:tblPr/w:tblBorders/w:right"/>
  609.                         </xsl:call-template>
  610.                     </xsl:otherwise>
  611.                 </xsl:choose>
  612.             </xsl:element>
  613.         </style:style>
  614.     </xsl:template>
  615.     <xsl:template name="get-table-border">
  616.         <xsl:param name="style-pos"/>
  617.         <xsl:param name="style-position-0"/>
  618.         <xsl:param name="style-position-1"/>
  619.         <xsl:param name="style-position-2"/>
  620.         <xsl:variable name="size-style">
  621.             <xsl:choose>
  622.                 <xsl:when test="$style-position-0">
  623.                     <xsl:value-of select="$style-position-0/@w:sz"/>
  624.                 </xsl:when>
  625.                 <xsl:when test="$style-position-1">
  626.                     <xsl:value-of select="$style-position-1/@w:sz"/>
  627.                 </xsl:when>
  628.                 <xsl:when test="$style-position-2">
  629.                     <xsl:value-of select="$style-position-2/@w:sz"/>
  630.                 </xsl:when>
  631.                 <xsl:otherwise>2</xsl:otherwise>
  632.             </xsl:choose>
  633.         </xsl:variable>
  634.         <xsl:variable name="border-style">
  635.             <xsl:choose>
  636.                 <xsl:when test="$style-position-0">
  637.                     <xsl:value-of select="$style-position-0/@w:val"/>
  638.                 </xsl:when>
  639.                 <xsl:when test="$style-position-1">
  640.                     <xsl:value-of select="$style-position-1/@w:val"/>
  641.                 </xsl:when>
  642.                 <xsl:when test="$style-position-2">
  643.                     <xsl:value-of select="$style-position-2/@w:val"/>
  644.                 </xsl:when>
  645.                 <xsl:otherwise>single</xsl:otherwise>
  646.             </xsl:choose>
  647.         </xsl:variable>
  648.         <!-- totally basic Word table border styles: nil, none, single, thick, double, dotted, dashed, dot-dash, dot-dot-dash, triple, thin-thick-small-gap, thick-thin-small-gap, thin-thick-thin-small-gap, thin-thick-medium-gap, thick-thin-medium-gap, thin-thick-thin-medium-gap, thin-thick-large-gap, thick-thin-large-gap, thin-thick-thin-large-gap, wave, double-wave, dash-small-gap, dash-dot-stroked, three-d-emboss, three-d-engrave, outset, inset. Others are advanced graphical table border styles. glu -->
  649.         <xsl:variable name="style-border">
  650.             <xsl:choose>
  651.                 <xsl:when test="$border-style = 'nil' or $border-style ='none'">hidden</xsl:when>
  652.                 <xsl:when test="$border-style = 'single' or $border-style = 'thick' or $border-style = 'dotted' or $border-style = 'dashed' or $border-style = 'dot-dash' or $border-style = 'dot-dot-dash' or $border-style = 'wave' or $border-style = 'dash-small-gap' or $border-style = 'dash-dot-stroked'">solid</xsl:when>
  653.                 <xsl:otherwise>double</xsl:otherwise>
  654.             </xsl:choose>
  655.         </xsl:variable>
  656.         <xsl:variable name="color-border">
  657.             <xsl:choose>
  658.                 <xsl:when test="$style-position-0 and string-length($style-position-0/@w:color) = 6">
  659.                     <xsl:value-of select="$style-position-0/@w:color"/>
  660.                 </xsl:when>
  661.                 <xsl:when test="$style-position-0 and $style-position-0/@w:color = 'auto' and contains($border-style, 'set')">
  662.                     <xsl:text>c0c0c0</xsl:text>
  663.                 </xsl:when>
  664.                 <xsl:when test="$style-position-1 and string-length($style-position-1/@w:color) = 6">
  665.                     <xsl:value-of select="$style-position-1/@w:color"/>
  666.                 </xsl:when>
  667.                 <xsl:when test="$style-position-1 and $style-position-1/@w:color = 'auto' and contains($border-style, 'set')">
  668.                     <xsl:text>c0c0c0</xsl:text>
  669.                 </xsl:when>
  670.                 <xsl:when test="$style-position-2 and string-length($style-position-2/@w:color) = 6">
  671.                     <xsl:value-of select="$style-position-2/@w:color"/>
  672.                 </xsl:when>
  673.                 <xsl:when test="$style-position-2 and $style-position-2/@w:color = 'auto' and contains($border-style, 'set')">
  674.                     <xsl:text>c0c0c0</xsl:text>
  675.                 </xsl:when>
  676.                 <xsl:otherwise>000000</xsl:otherwise>
  677.             </xsl:choose>
  678.         </xsl:variable>
  679.         <!-- mapping border line widths. glu -->
  680.         <xsl:choose>
  681.             <xsl:when test="$border-style = 'single'">
  682.                 <xsl:choose>
  683.                     <xsl:when test="$size-style < 7">
  684.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  685.                             <xsl:value-of select="concat('0.002cm solid #', $color-border)"/>
  686.                         </xsl:attribute>
  687.                     </xsl:when>
  688.                     <xsl:when test="$size-style < 20">
  689.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  690.                             <xsl:value-of select="concat('0.035cm solid #', $color-border)"/>
  691.                         </xsl:attribute>
  692.                     </xsl:when>
  693.                     <xsl:when test="$size-style < 30">
  694.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  695.                             <xsl:value-of select="concat('0.088cm solid #', $color-border)"/>
  696.                         </xsl:attribute>
  697.                     </xsl:when>
  698.                     <xsl:when test="$size-style < 40">
  699.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  700.                             <xsl:value-of select="concat('0.141cm solid #', $color-border)"/>
  701.                         </xsl:attribute>
  702.                     </xsl:when>
  703.                     <xsl:otherwise>
  704.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  705.                             <xsl:value-of select="concat('0.176cm solid #', $color-border)"/>
  706.                         </xsl:attribute>
  707.                     </xsl:otherwise>
  708.                 </xsl:choose>
  709.             </xsl:when>
  710.             <xsl:when test="$border-style = 'double'">
  711.                 <xsl:choose>
  712.                     <xsl:when test="$size-style < 10">
  713.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  714.                             <xsl:value-of select="concat('0.039cm double #', $color-border)"/>
  715.                         </xsl:attribute>
  716.                         <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.035cm 0.002cm</xsl:attribute>
  717.                     </xsl:when>
  718.                     <xsl:when test="$size-style < 15">
  719.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  720.                             <xsl:value-of select="concat('0.092cm double #', $color-border)"/>
  721.                         </xsl:attribute>
  722.                         <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.002cm</xsl:attribute>
  723.                     </xsl:when>
  724.                     <xsl:when test="$size-style < 20">
  725.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  726.                             <xsl:value-of select="concat('0.106cm double #', $color-border)"/>
  727.                         </xsl:attribute>
  728.                         <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.035cm 0.035cm 0.035cm</xsl:attribute>
  729.                     </xsl:when>
  730.                     <xsl:otherwise>
  731.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  732.                             <xsl:value-of select="concat('0.265cm double #', $color-border)"/>
  733.                         </xsl:attribute>
  734.                         <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.088cm 0.088cm</xsl:attribute>
  735.                     </xsl:otherwise>
  736.                 </xsl:choose>
  737.             </xsl:when>
  738.             <xsl:when test="$border-style = 'triple'">
  739.                 <xsl:choose>
  740.                     <xsl:when test="$size-style < 5">
  741.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  742.                             <xsl:value-of select="concat('0.039cm double #', $color-border)"/>
  743.                         </xsl:attribute>
  744.                         <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.035cm 0.002cm</xsl:attribute>
  745.                     </xsl:when>
  746.                     <xsl:when test="$size-style < 10">
  747.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  748.                             <xsl:value-of select="concat('0.092cm double #', $color-border)"/>
  749.                         </xsl:attribute>
  750.                         <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">.002cm 0.088cm 0.002cm</xsl:attribute>
  751.                     </xsl:when>
  752.                     <xsl:when test="$size-style < 15">
  753.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  754.                             <xsl:value-of select="concat('0.106cm double #', $color-border)"/>
  755.                         </xsl:attribute>
  756.                         <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.035cm 0.035cm 0.035cm</xsl:attribute>
  757.                     </xsl:when>
  758.                     <xsl:otherwise>
  759.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  760.                             <xsl:value-of select="concat('0.265cm double #', $color-border)"/>
  761.                         </xsl:attribute>
  762.                         <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.088cm 0.088cm</xsl:attribute>
  763.                     </xsl:otherwise>
  764.                 </xsl:choose>
  765.             </xsl:when>
  766.             <xsl:when test="$border-style = 'thin-thick-small-gap' or $border-style = 'thick-thin-small-gap'">
  767.                 <xsl:choose>
  768.                     <xsl:when test="($border-style = 'thin-thick-small-gap' and ($style-pos = 'left' or $style-pos = 'top')) or ($border-style = 'thick-thin-small-gap' and ($style-pos = 'right' or $style-pos = 'bottom'))">
  769.                         <xsl:choose>
  770.                             <xsl:when test="$size-style < 20">
  771.                                 <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  772.                                     <xsl:value-of select="concat('0.125cm double #', $color-border)"/>
  773.                                 </xsl:attribute>
  774.                                 <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.035cm</xsl:attribute>
  775.                             </xsl:when>
  776.                             <xsl:when test="$size-style < 30">
  777.                                 <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  778.                                     <xsl:value-of select="concat('0.178cm double #', $color-border)"/>
  779.                                 </xsl:attribute>
  780.                                 <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.088cm</xsl:attribute>
  781.                             </xsl:when>
  782.                             <xsl:otherwise>
  783.                                 <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  784.                                     <xsl:value-of select="concat('0.231cm double #', $color-border)"/>
  785.                                 </xsl:attribute>
  786.                                 <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.141cm</xsl:attribute>
  787.                             </xsl:otherwise>
  788.                         </xsl:choose>
  789.                     </xsl:when>
  790.                     <xsl:otherwise>
  791.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  792.                             <xsl:value-of select="concat('0.159cm double #', $color-border)"/>
  793.                         </xsl:attribute>
  794.                         <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.035cm 0.035cm</xsl:attribute>
  795.                     </xsl:otherwise>
  796.                 </xsl:choose>
  797.             </xsl:when>
  798.             <xsl:when test="$border-style = 'thin-thick-thin-small-gap'">
  799.                 <xsl:choose>
  800.                     <xsl:when test="$size-style < 20">
  801.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  802.                             <xsl:value-of select="concat('0.178cm double #', $color-border)"/>
  803.                         </xsl:attribute>
  804.                         <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.088cm</xsl:attribute>
  805.                     </xsl:when>
  806.                     <xsl:when test="$size-style < 40">
  807.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  808.                             <xsl:value-of select="concat('0.231cm double #', $color-border)"/>
  809.                         </xsl:attribute>
  810.                         <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.141cm</xsl:attribute>
  811.                     </xsl:when>
  812.                     <xsl:otherwise>
  813.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  814.                             <xsl:value-of select="concat('0.318cm double #', $color-border)"/>
  815.                         </xsl:attribute>
  816.                         <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.088cm 0.141cm</xsl:attribute>
  817.                     </xsl:otherwise>
  818.                 </xsl:choose>
  819.             </xsl:when>
  820.             <xsl:when test="$border-style = 'thin-thick-medium-gap' or $border-style = 'thick-thin-medium-gap'">
  821.                 <xsl:choose>
  822.                     <xsl:when test="$size-style < 10">
  823.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  824.                             <xsl:value-of select="concat('0.039cm double #', $color-border)"/>
  825.                         </xsl:attribute>
  826.                         <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.035cm 0.002cm</xsl:attribute>
  827.                     </xsl:when>
  828.                     <xsl:when test="$size-style < 15">
  829.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  830.                             <xsl:value-of select="concat('0.106cm double #', $color-border)"/>
  831.                         </xsl:attribute>
  832.                         <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.035cm 0.035cm 0.035cm</xsl:attribute>
  833.                     </xsl:when>
  834.                     <xsl:when test="$size-style < 30">
  835.                         <xsl:choose>
  836.                             <xsl:when test="($border-style = 'thin-thick-medium-gap' and ($style-pos = 'left' or $style-pos = 'top')) or ($border-style = 'thick-thin-medium-gap' and ($style-pos = 'right' or $style-pos = 'bottom'))">
  837.                                 <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  838.                                     <xsl:value-of select="concat('0.212cm double #', $color-border)"/>
  839.                                 </xsl:attribute>
  840.                                 <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.035cm 0.088cm 0.088cm</xsl:attribute>
  841.                             </xsl:when>
  842.                             <xsl:otherwise>
  843.                                 <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  844.                                     <xsl:value-of select="concat('0.159cm double #', $color-border)"/>
  845.                                 </xsl:attribute>
  846.                                 <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.035cm 0.035cm</xsl:attribute>
  847.                             </xsl:otherwise>
  848.                         </xsl:choose>
  849.                     </xsl:when>
  850.                     <xsl:otherwise>
  851.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  852.                             <xsl:value-of select="concat('0.318cm double #', $color-border)"/>
  853.                         </xsl:attribute>
  854.                         <xsl:choose>
  855.                             <xsl:when test="($border-style = 'thin-thick-medium-gap' and ($style-pos = 'left' or $style-pos = 'top')) or ($border-style = 'thick-thin-medium-gap' and ($style-pos = 'right' or $style-pos = 'bottom'))">
  856.                                 <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.088cm 0.141cm</xsl:attribute>
  857.                             </xsl:when>
  858.                             <xsl:otherwise>
  859.                                 <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.141cm 0.088cm 0.088cm</xsl:attribute>
  860.                             </xsl:otherwise>
  861.                         </xsl:choose>
  862.                     </xsl:otherwise>
  863.                 </xsl:choose>
  864.             </xsl:when>
  865.             <xsl:when test="$border-style = 'thin-thick-thin-medium-gap'">
  866.                 <xsl:choose>
  867.                     <xsl:when test="$size-style < 10">
  868.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  869.                             <xsl:value-of select="concat('0.039cm double #', $color-border)"/>
  870.                         </xsl:attribute>
  871.                         <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.035cm 0.002cm</xsl:attribute>
  872.                     </xsl:when>
  873.                     <xsl:when test="$size-style < 15">
  874.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  875.                             <xsl:value-of select="concat('0.106cm double #', $color-border)"/>
  876.                         </xsl:attribute>
  877.                         <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.035cm 0.035cm 0.035cm</xsl:attribute>
  878.                     </xsl:when>
  879.                     <xsl:when test="$size-style < 30">
  880.                         <xsl:choose>
  881.                             <xsl:when test="$style-pos = 'left' or $style-pos = 'top'">
  882.                                 <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  883.                                     <xsl:value-of select="concat('0.159cm double #', $color-border)"/>
  884.                                 </xsl:attribute>
  885.                                 <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.035cm 0.035cm</xsl:attribute>
  886.                             </xsl:when>
  887.                             <xsl:otherwise>
  888.                                 <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  889.                                     <xsl:value-of select="concat('0.212cm double #', $color-border)"/>
  890.                                 </xsl:attribute>
  891.                                 <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.035cm 0.088cm 0.088cm</xsl:attribute>
  892.                             </xsl:otherwise>
  893.                         </xsl:choose>
  894.                     </xsl:when>
  895.                     <xsl:otherwise>
  896.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  897.                             <xsl:value-of select="concat('0.318cm double #', $color-border)"/>
  898.                         </xsl:attribute>
  899.                         <xsl:choose>
  900.                             <xsl:when test="$style-pos = 'left' or $style-pos = 'top'">
  901.                                 <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.141cm 0.088cm 0.088cm</xsl:attribute>
  902.                             </xsl:when>
  903.                             <xsl:otherwise>
  904.                                 <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.088cm 0.141cm</xsl:attribute>
  905.                             </xsl:otherwise>
  906.                         </xsl:choose>
  907.                     </xsl:otherwise>
  908.                 </xsl:choose>
  909.             </xsl:when>
  910.             <xsl:when test="$border-style = 'thin-thick-large-gap' or $border-style = 'thick-thin-large-gap'">
  911.                 <xsl:choose>
  912.                     <xsl:when test="$size-style < 7">
  913.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  914.                             <xsl:value-of select="concat('0.092cm double #', $color-border)"/>
  915.                         </xsl:attribute>
  916.                         <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.002cm</xsl:attribute>
  917.                     </xsl:when>
  918.                     <xsl:when test="$size-style < 10">
  919.                         <xsl:choose>
  920.                             <xsl:when test="($border-style = 'thin-thick-large-gap' and ($style-pos = 'left' or $style-pos = 'top')) or ($border-style = 'thick-thin-large-gap' and ($style-pos = 'right' or $style-pos = 'bottom'))">
  921.                                 <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  922.                                     <xsl:value-of select="concat('0.125cm double #', $color-border)"/>
  923.                                 </xsl:attribute>
  924.                                 <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.035cm</xsl:attribute>
  925.                             </xsl:when>
  926.                             <xsl:otherwise>
  927.                                 <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  928.                                     <xsl:value-of select="concat('0.092cm double #', $color-border)"/>
  929.                                 </xsl:attribute>
  930.                                 <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.002cm</xsl:attribute>
  931.                             </xsl:otherwise>
  932.                         </xsl:choose>
  933.                     </xsl:when>
  934.                     <xsl:when test="$size-style < 15">
  935.                         <xsl:choose>
  936.                             <xsl:when test="($border-style = 'thin-thick-large-gap' and ($style-pos = 'left' or $style-pos = 'top')) or ($border-style = 'thick-thin-large-gap' and ($style-pos = 'right' or $style-pos = 'bottom'))">
  937.                                 <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  938.                                     <xsl:value-of select="concat('0.125cm double #', $color-border)"/>
  939.                                 </xsl:attribute>
  940.                                 <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.035cm</xsl:attribute>
  941.                             </xsl:when>
  942.                             <xsl:otherwise>
  943.                                 <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  944.                                     <xsl:value-of select="concat('0.159cm double #', $color-border)"/>
  945.                                 </xsl:attribute>
  946.                                 <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.035cm 0.035cm</xsl:attribute>
  947.                             </xsl:otherwise>
  948.                         </xsl:choose>
  949.                     </xsl:when>
  950.                     <xsl:when test="$size-style < 30">
  951.                         <xsl:choose>
  952.                             <xsl:when test="($border-style = 'thin-thick-large-gap' and ($style-pos = 'left' or $style-pos = 'top')) or ($border-style = 'thick-thin-large-gap' and ($style-pos = 'right' or $style-pos = 'bottom'))">
  953.                                 <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  954.                                     <xsl:value-of select="concat('0.178cm double #', $color-border)"/>
  955.                                 </xsl:attribute>
  956.                                 <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.088cm</xsl:attribute>
  957.                             </xsl:when>
  958.                             <xsl:otherwise>
  959.                                 <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  960.                                     <xsl:value-of select="concat('0.159cm double #', $color-border)"/>
  961.                                 </xsl:attribute>
  962.                                 <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.035cm 0.035cm</xsl:attribute>
  963.                             </xsl:otherwise>
  964.                         </xsl:choose>
  965.                     </xsl:when>
  966.                     <xsl:when test="$size-style < 40">
  967.                         <xsl:choose>
  968.                             <xsl:when test="($border-style = 'thin-thick-large-gap' and ($style-pos = 'left' or $style-pos = 'top')) or ($border-style = 'thick-thin-large-gap' and ($style-pos = 'right' or $style-pos = 'bottom'))">
  969.                                 <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  970.                                     <xsl:value-of select="concat('0.231cm double #', $color-border)"/>
  971.                                 </xsl:attribute>
  972.                                 <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.141cm</xsl:attribute>
  973.                             </xsl:when>
  974.                             <xsl:otherwise>
  975.                                 <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  976.                                     <xsl:value-of select="concat('0.159cm double #', $color-border)"/>
  977.                                 </xsl:attribute>
  978.                                 <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.035cm 0.035cm</xsl:attribute>
  979.                             </xsl:otherwise>
  980.                         </xsl:choose>
  981.                     </xsl:when>
  982.                     <xsl:otherwise>
  983.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  984.                             <xsl:value-of select="concat('0.318cm double #', $color-border)"/>
  985.                         </xsl:attribute>
  986.                         <xsl:choose>
  987.                             <xsl:when test="($border-style = 'thin-thick-large-gap' and ($style-pos = 'left' or $style-pos = 'top')) or ($border-style = 'thick-thin-large-gap' and ($style-pos = 'right' or $style-pos = 'bottom'))">
  988.                                 <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.088cm 0.141cm</xsl:attribute>
  989.                             </xsl:when>
  990.                             <xsl:otherwise>
  991.                                 <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.141cm 0.088cm 0.088cm</xsl:attribute>
  992.                             </xsl:otherwise>
  993.                         </xsl:choose>
  994.                     </xsl:otherwise>
  995.                 </xsl:choose>
  996.             </xsl:when>
  997.             <xsl:when test="$border-style = 'thin-thick-thin-large-gap'">
  998.                 <xsl:choose>
  999.                     <xsl:when test="$size-style < 5">
  1000.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  1001.                             <xsl:value-of select="concat('0.125cm double #', $color-border)"/>
  1002.                         </xsl:attribute>
  1003.                         <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.035cm</xsl:attribute>
  1004.                     </xsl:when>
  1005.                     <xsl:when test="$size-style < 10">
  1006.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  1007.                             <xsl:value-of select="concat('0.178cm double #', $color-border)"/>
  1008.                         </xsl:attribute>
  1009.                         <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.088cm</xsl:attribute>
  1010.                     </xsl:when>
  1011.                     <xsl:when test="$size-style < 20">
  1012.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  1013.                             <xsl:value-of select="concat('0.231cm double #', $color-border)"/>
  1014.                         </xsl:attribute>
  1015.                         <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.141cm</xsl:attribute>
  1016.                     </xsl:when>
  1017.                     <xsl:otherwise>
  1018.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  1019.                             <xsl:value-of select="concat('0.318cm double #', $color-border)"/>
  1020.                         </xsl:attribute>
  1021.                         <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.088cm 0.141cm</xsl:attribute>
  1022.                     </xsl:otherwise>
  1023.                 </xsl:choose>
  1024.             </xsl:when>
  1025.             <xsl:when test="contains( $border-style, 'wave') or $border-style = 'dash-dot-stroked'">
  1026.                 <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  1027.                     <xsl:value-of select="concat('0.106cm double #', $color-border)"/>
  1028.                 </xsl:attribute>
  1029.                 <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.035cm 0.035cm 0.035cm</xsl:attribute>
  1030.             </xsl:when>
  1031.             <xsl:when test="contains( $border-style, 'three-d')">
  1032.                 <xsl:choose>
  1033.                     <xsl:when test="$size-style < 10">
  1034.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  1035.                             <xsl:value-of select="concat('0.035cm solid #', $color-border)"/>
  1036.                         </xsl:attribute>
  1037.                     </xsl:when>
  1038.                     <xsl:when test="$size-style < 20">
  1039.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  1040.                             <xsl:value-of select="concat('0.088cm solid #', $color-border)"/>
  1041.                         </xsl:attribute>
  1042.                     </xsl:when>
  1043.                     <xsl:when test="$size-style < 30">
  1044.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  1045.                             <xsl:value-of select="concat('0.176cm solid #', $color-border)"/>
  1046.                         </xsl:attribute>
  1047.                     </xsl:when>
  1048.                     <xsl:when test="$size-style < 40">
  1049.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  1050.                             <xsl:value-of select="concat('0.265cm double #', $color-border)"/>
  1051.                         </xsl:attribute>
  1052.                         <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.088cm 0.088cm</xsl:attribute>
  1053.                     </xsl:when>
  1054.                     <xsl:otherwise>
  1055.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  1056.                             <xsl:value-of select="concat('0.318cm double #', $color-border)"/>
  1057.                         </xsl:attribute>
  1058.                         <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.088cm 0.141cm</xsl:attribute>
  1059.                     </xsl:otherwise>
  1060.                 </xsl:choose>
  1061.             </xsl:when>
  1062.             <xsl:when test="contains( $border-style, 'set')">
  1063.                 <xsl:choose>
  1064.                     <xsl:when test="$size-style < 7">
  1065.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  1066.                             <xsl:value-of select="concat('0.092cm double #', $color-border)"/>
  1067.                         </xsl:attribute>
  1068.                         <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.002cm</xsl:attribute>
  1069.                     </xsl:when>
  1070.                     <xsl:when test="$size-style < 10">
  1071.                         <xsl:choose>
  1072.                             <xsl:when test="($border-style = 'outset' and ($style-pos = 'left' or $style-pos = 'top')) or ($border-style = 'inset' and ($style-pos = 'right' or $style-pos = 'bottom'))">
  1073.                                 <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  1074.                                     <xsl:value-of select="concat('0.092cm double #', $color-border)"/>
  1075.                                 </xsl:attribute>
  1076.                                 <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.002cm</xsl:attribute>
  1077.                             </xsl:when>
  1078.                             <xsl:otherwise>
  1079.                                 <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  1080.                                     <xsl:value-of select="concat('0.125cm double #', $color-border)"/>
  1081.                                 </xsl:attribute>
  1082.                                 <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.035cm</xsl:attribute>
  1083.                             </xsl:otherwise>
  1084.                         </xsl:choose>
  1085.                     </xsl:when>
  1086.                     <xsl:when test="$size-style < 15">
  1087.                         <xsl:choose>
  1088.                             <xsl:when test="($border-style = 'outset' and ($style-pos = 'left' or $style-pos = 'top')) or ($border-style = 'inset' and ($style-pos = 'right' or $style-pos = 'bottom'))">
  1089.                                 <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  1090.                                     <xsl:value-of select="concat('0.159cm double #', $color-border)"/>
  1091.                                 </xsl:attribute>
  1092.                                 <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.035cm 0.035cm</xsl:attribute>
  1093.                             </xsl:when>
  1094.                             <xsl:otherwise>
  1095.                                 <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  1096.                                     <xsl:value-of select="concat('0.125cm double #', $color-border)"/>
  1097.                                 </xsl:attribute>
  1098.                                 <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.035cm</xsl:attribute>
  1099.                             </xsl:otherwise>
  1100.                         </xsl:choose>
  1101.                     </xsl:when>
  1102.                     <xsl:when test="$size-style < 30">
  1103.                         <xsl:choose>
  1104.                             <xsl:when test="($border-style = 'outset' and ($style-pos = 'left' or $style-pos = 'top')) or ($border-style = 'inset' and ($style-pos = 'right' or $style-pos = 'bottom'))">
  1105.                                 <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  1106.                                     <xsl:value-of select="concat('0.159cm double #', $color-border)"/>
  1107.                                 </xsl:attribute>
  1108.                                 <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.035cm 0.035cm</xsl:attribute>
  1109.                             </xsl:when>
  1110.                             <xsl:otherwise>
  1111.                                 <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  1112.                                     <xsl:value-of select="concat('0.178cm double #', $color-border)"/>
  1113.                                 </xsl:attribute>
  1114.                                 <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.088cm</xsl:attribute>
  1115.                             </xsl:otherwise>
  1116.                         </xsl:choose>
  1117.                     </xsl:when>
  1118.                     <xsl:when test="$size-style < 40">
  1119.                         <xsl:choose>
  1120.                             <xsl:when test="($border-style = 'outset' and ($style-pos = 'left' or $style-pos = 'top')) or ($border-style = 'inset' and ($style-pos = 'right' or $style-pos = 'bottom'))">
  1121.                                 <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  1122.                                     <xsl:value-of select="concat('0.159cm double #', $color-border)"/>
  1123.                                 </xsl:attribute>
  1124.                                 <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.035cm 0.035cm</xsl:attribute>
  1125.                             </xsl:when>
  1126.                             <xsl:otherwise>
  1127.                                 <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  1128.                                     <xsl:value-of select="concat('0.231cm double #', $color-border)"/>
  1129.                                 </xsl:attribute>
  1130.                                 <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.002cm 0.088cm 0.141cm</xsl:attribute>
  1131.                             </xsl:otherwise>
  1132.                         </xsl:choose>
  1133.                     </xsl:when>
  1134.                     <xsl:otherwise>
  1135.                         <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  1136.                             <xsl:value-of select="concat('0.318cm double #', $color-border)"/>
  1137.                         </xsl:attribute>
  1138.                         <xsl:choose>
  1139.                             <xsl:when test="($border-style = 'outset' and ($style-pos = 'left' or $style-pos = 'top')) or ($border-style = 'inset' and ($style-pos = 'right' or $style-pos = 'bottom'))">
  1140.                                 <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.141cm 0.088cm 0.088cm</xsl:attribute>
  1141.                             </xsl:when>
  1142.                             <xsl:otherwise>
  1143.                                 <xsl:attribute name="{concat('fo:border-', $style-pos)}">
  1144.                                     <xsl:value-of select="concat('0.231cm double #', $color-border)"/>
  1145.                                 </xsl:attribute>
  1146.                                 <xsl:attribute name="{concat('style:border-line-width-',$style-pos)}">0.088cm 0.088cm 0.141cm</xsl:attribute>
  1147.                             </xsl:otherwise>
  1148.                         </xsl:choose>
  1149.                     </xsl:otherwise>
  1150.                 </xsl:choose>
  1151.             </xsl:when>
  1152.             <xsl:otherwise>
  1153.                 <xsl:attribute name="{concat('fo:border-', $style-pos)}">0.002cm solid #000000</xsl:attribute>
  1154.             </xsl:otherwise>
  1155.         </xsl:choose>
  1156.     </xsl:template>
  1157.     <xsl:template match="w:tbl">
  1158.         <xsl:choose>
  1159.             <xsl:when test="w:tblPr/w:tblpPr">
  1160.                 <!-- if the table is surrounded by text then put the table into a draw:text-box -->
  1161.                 <xsl:element name="text:p">
  1162.                     <xsl:element name="draw:frame">
  1163.                         <xsl:attribute name="draw:style-name">
  1164.                             <xsl:text>TableFrame</xsl:text>
  1165.                             <xsl:number count="w:tblpPr" from="/w:wordDocument/w:body" level="any" format="1"/>
  1166.                         </xsl:attribute>
  1167.                         <xsl:attribute name="draw:name">TableFr<xsl:number count="w:tblpPr" from="/w:wordDocument/w:body" level="any" format="1"/>
  1168.                         </xsl:attribute>
  1169.                         <xsl:variable name="tbl_anchor_type">
  1170.                             <xsl:choose>
  1171.                                 <xsl:when test="name(..) = 'w:tc' ">
  1172.                                     <xsl:text>as-char</xsl:text>
  1173.                                 </xsl:when>
  1174.                                 <xsl:otherwise>
  1175.                                     <xsl:text>paragraph</xsl:text>
  1176.                                 </xsl:otherwise>
  1177.                             </xsl:choose>
  1178.                         </xsl:variable>
  1179.                         <xsl:attribute name="text:anchor-type">
  1180.                             <xsl:value-of select="$tbl_anchor_type"/>
  1181.                         </xsl:attribute>
  1182.                         <xsl:variable name="tbl_draw_textbox_width">
  1183.                             <xsl:call-template name="ConvertMeasure">
  1184.                                 <xsl:with-param name="TargetMeasure" select="'in'"/>
  1185.                                 <!--  adjust the width of draw:text-box containing a table with 20dxa + table-width -->
  1186.                                 <xsl:with-param name="value" select="concat(string(number(sum(w:tblGrid/w:gridCol/@w:w) +20)), 'twip' )"/>
  1187.                             </xsl:call-template>
  1188.                         </xsl:variable>
  1189.                         <xsl:attribute name="svg:width">
  1190.                             <xsl:value-of select="concat ($tbl_draw_textbox_width, 'in') "/>
  1191.                         </xsl:attribute>
  1192.                         <xsl:if test="w:tblPr/w:tblpPr/@w:tblpX">
  1193.                             <xsl:variable name="x_distance_from_anchor">
  1194.                                 <xsl:call-template name="ConvertMeasure">
  1195.                                     <xsl:with-param name="TargetMeasure" select="'in'"/>
  1196.                                     <xsl:with-param name="value" select="concat(w:tblPr/w:tblpPr/@w:tblpX, 'twip' ) "/>
  1197.                                 </xsl:call-template>
  1198.                             </xsl:variable>
  1199.                             <xsl:attribute name="svg:x">
  1200.                                 <xsl:value-of select="concat ($x_distance_from_anchor, 'in' )"/>
  1201.                             </xsl:attribute>
  1202.                         </xsl:if>
  1203.                         <xsl:if test="w:tblPr/w:tblpPr/@w:tblpY">
  1204.                             <xsl:variable name="y_distance_from_anchor">
  1205.                                 <xsl:call-template name="ConvertMeasure">
  1206.                                     <xsl:with-param name="TargetMeasure" select="'in'"/>
  1207.                                     <xsl:with-param name="value" select="concat(w:tblPr/w:tblpPr/@w:tblpY, 'twip' ) "/>
  1208.                                 </xsl:call-template>
  1209.                             </xsl:variable>
  1210.                             <xsl:attribute name="svg:y">
  1211.                                 <xsl:value-of select="concat ($y_distance_from_anchor, 'in' )"/>
  1212.                             </xsl:attribute>
  1213.                         </xsl:if>
  1214.                         <!--create table in draw:text-box to produce table wrapping text effect-->
  1215.                         <xsl:element name="draw:text-box">
  1216.                             <xsl:element name="table:table">
  1217.                                 <xsl:if test="w:tblPr">
  1218.                                     <xsl:attribute name="table:style-name">Table<xsl:number count="w:tbl" from="/w:wordDocument/w:body" level="any" format="1"/>
  1219.                                     </xsl:attribute>
  1220.                                 </xsl:if>
  1221.                                 <xsl:apply-templates select="w:tblGrid | w:tr"/>
  1222.                             </xsl:element>
  1223.                         </xsl:element>
  1224.                     </xsl:element>
  1225.                     <!--draw:text-box end  -->
  1226.                 </xsl:element>
  1227.                 <!-- text:p end -->
  1228.             </xsl:when>
  1229.             <xsl:otherwise>
  1230.                 <!-- if the table is not surrounded by text then put the table into a draw:text-box -->
  1231.                 <xsl:element name="table:table">
  1232.                     <xsl:if test="w:tblPr">
  1233.                         <xsl:attribute name="table:style-name">Table<xsl:number count="w:tbl" from="/w:wordDocument/w:body" level="any" format="1"/>
  1234.                         </xsl:attribute>
  1235.                     </xsl:if>
  1236.                     <xsl:apply-templates select="w:tblGrid | w:tr"/>
  1237.                 </xsl:element>
  1238.             </xsl:otherwise>
  1239.         </xsl:choose>
  1240.     </xsl:template>
  1241.     <xsl:template match="w:tblGrid">
  1242.         <xsl:apply-templates select="w:gridCol"/>
  1243.     </xsl:template>
  1244.     <xsl:template match="w:gridCol">
  1245.         <xsl:element name="table:table-column">
  1246.             <xsl:attribute name="table:style-name">Table<xsl:number count="w:tbl" from="/w:wordDocument/w:body" level="any" format="1"/>.C<xsl:number count="w:gridCol" from="/w:wordDocument/w:body" level="single" format="1"/>
  1247.             </xsl:attribute>
  1248.         </xsl:element>
  1249.     </xsl:template>
  1250.     <xsl:template match="w:tr">
  1251.         <xsl:element name="table:table-row">
  1252.             <!-- generate row in table and add attribute of table:style-name if the style:style exists. cp tom chen. -->
  1253.             <xsl:if test="w:trPr/w:trHeight">
  1254.                 <xsl:attribute name="table:style-name">Table<xsl:number count="w:tbl" from="/w:wordDocument/w:body" level="any" format="1"/>.R<xsl:number count="w:tr" from="/w:wordDocument/w:body" level="single" format="1"/>
  1255.                 </xsl:attribute>
  1256.             </xsl:if>
  1257.             <xsl:apply-templates select="w:tc"/>
  1258.         </xsl:element>
  1259.     </xsl:template>
  1260.     <xsl:template match="w:tc">
  1261.         <xsl:element name="table:table-cell">
  1262.             <xsl:attribute name="table:style-name">Table<xsl:number count="w:tbl" from="/w:wordDocument/w:body" level="any" format="1"/>.R<xsl:number count="w:tr" from="/w:wordDocument/w:body" level="single" format="1"/>C<xsl:number count="w:tc" from="/w:wordDocument/w:body" level="single" format="1"/>
  1263.             </xsl:attribute>
  1264.             <xsl:if test="w:tcPr/w:gridSpan and w:tcPr/w:gridSpan/@w:val > 0">
  1265.                 <xsl:attribute name="table:number-columns-spanned">
  1266.                     <xsl:value-of select="w:tcPr/w:gridSpan/@w:val"/>
  1267.                 </xsl:attribute>
  1268.             </xsl:if>
  1269.             <xsl:apply-templates select="w:p | w:tbl"/>
  1270.         </xsl:element>
  1271.     </xsl:template>
  1272.     <xsl:template name="convert2in_special">
  1273.         <!-- this template is specially to  deal with w:type ='dxa' situation -->
  1274.         <xsl:param name="orignal_value"/>
  1275.         <xsl:choose>
  1276.             <xsl:when test="contains($orignal_value, 'dxa') ">
  1277.                 <xsl:variable name="table_measurement_new_value">
  1278.                     <xsl:value-of select="concat( substring-before($orignal_value,'dxa'), 'twip')"/>
  1279.                 </xsl:variable>
  1280.                 <xsl:call-template name="ConvertMeasure">
  1281.                     <xsl:with-param name="TargetMeasure" select="'in'"/>
  1282.                     <xsl:with-param name="value" select="$table_measurement_new_value"/>
  1283.                 </xsl:call-template>
  1284.             </xsl:when>
  1285.         </xsl:choose>
  1286.     </xsl:template>
  1287. </xsl:stylesheet>
  1288.